<!--
 * @Author: cgl
 * @Date: 2023-04-18 15:12:26
 * @LastEditors: liangkun 2669681641@qq.com
 * @LastEditTime: 2023-11-22 09:36:40
 * @FilePath: \radiation-hygiene-fe\src\views\report\personnelReport.vue
 * @Description:
 *
 * Copyright (c) 2023 by cgl/微盛信息产业有限公司, All Rights Reserved.
-->
<template>
  <div class="app-container">
    <el-form
      class="searchform"
      :model="queryParams"
      ref="queryParams"
      size="small"
      label-width="80px"
    >
      <el-row :gutter="20">
        <el-col :span="5">
          <el-form-item label="合同编号">
            <el-input
              v-model="queryParams.agreementNumber"
              placeholder="请输入"
              clearable
              @keyup.enter.native="getList()"
            />
          </el-form-item>
        </el-col>
        <el-col :span="5">
          <el-form-item label="联系人">
            <el-input
              v-model="queryParams.contactsName"
              placeholder="请输入"
              clearable
              @keyup.enter.native="getList()"
            />
          </el-form-item>
        </el-col>
        <el-col :span="5">
          <el-form-item label="状态">
            <el-select
              v-model="queryParams.tasksState"
              clearable
              style="width: 100%"
            >
              <el-option
                v-for="dict in dict.type.person_report_status"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="9">
          <el-form-item label-width="20px">
            <el-button
              type="primary"
              icon="el-icon-search"
              size="mini"
              @click="getList()"
              >搜索</el-button
            >
            <el-button icon="el-icon-refresh" size="mini" @click="reset()"
              >重置</el-button
            >
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>

    <!-- <div class="tableoperation"> -->
    <!-- <el-button type="primary" icon="el-icon-plus" size="mini" v-hasPermi="['task:personalDosimeter:add']" @click.native.prevent="openDialog()">添加</el-button> -->
    <!-- </div> -->

    <!-- <el-tabs v-model="activeName" @tab-click="changeTab" class="tab">
			<el-tab-pane label="待办理" name="-4" v-if="isPer"></el-tab-pane>
			<el-tab-pane label="待绑定" name="-2"></el-tab-pane>
			<el-tab-pane label="待检测" name="-1"></el-tab-pane>
			<el-tab-pane label="待审批" name="1"></el-tab-pane>
			<el-tab-pane label="已通过" name="2"></el-tab-pane>
		</el-tabs> -->
    <el-table
      :height="height - 350 + 'px'"
      v-loading="loading"
      :data="personalDosimeterReportList"
      @row-dblclick="(row) => openhandleDialog(row, '3')"
    >
      <el-table-column label="序号" type="index" align="center" />
      <el-table-column label="合同编号" align="center" prop="agreementNumber" />
      <el-table-column
        label="委托单位"
        align="center"
        prop="organizationName"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="联系人"
        align="center"
        prop="contactsName"
        width="120"
      />
      <el-table-column
        label="联系电话"
        align="center"
        prop="contactsMobile"
        width="150"
      />
      <el-table-column
        label="单位地址"
        align="center"
        prop="organizationAddress"
        width="150"
        :show-overflow-tooltip="true"
      />
      <el-table-column label="检测人员" align="center" prop="personNum" />
      <el-table-column label="录入时间" align="center" prop="createTime" />
      <el-table-column label="年份" align="center" prop="year" width="100" />
      <el-table-column label="批次" align="center" prop="batchNum" width="60" />
      <el-table-column label="批次" align="center" prop="batchNum" width="60" />
      <el-table-column label="状态" align="center">
        <template slot-scope="scope">
          <dict-tag
            :value="scope.row.tasksState"
            :options="dict.type.person_report_status"
          ></dict-tag>
        </template>
      </el-table-column>
      <el-table-column align="center" label="操作">
        <template slot-scope="scope">
          <el-button
            type="text"
            class="ovbutton"
            @click="downloadReport(scope.row.ossId)"
            v-if="scope.row.tasksState == '2' && scope.row.ossId"
          >
            下载报告
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加弹框 -->
    <el-dialog
      :title="title"
      :visible.sync="dialogVisible"
      :close-on-click-modal="false"
      width="1200px"
      class="addtask"
      v-dialogDrag="true"
    >
      <el-form
        :model="form"
        :disabled="status == '3'"
        :rules="rules"
        ref="form"
        size="small"
        label-width="100px"
        class="addform"
      >
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="单位名称" prop="entrustOrganizationId">
              <el-select
                v-model="form.entrustOrganizationId"
                :placeholder="status != '3' ? '输入文字检索查询' : ''"
                style="width: 100%"
                @change="changeEntrustOrganizationId"
                filterable
                clearable
              >
                <el-option
                  :label="item.organizationName"
                  :value="item.entrustOrganizationId"
                  v-for="(item, index) in entrustOrganizationSelect"
                  :key="index"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="合同编号">
              <el-select
                v-model="form.agreementId"
                :placeholder="status != '3' ? '请选择' : ''"
                style="width: 100%"
                clearable
              >
                <el-option
                  :label="item.agreementNumber"
                  :value="item.agreementId"
                  v-for="(item, index) in agreementList"
                  :key="index"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="联系人">
              <el-input v-model="form.contactsName" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="联系电话">
              <el-input v-model="form.contactsMobile" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="检测周期(天)">
              <el-input-number
                v-model="form.monitoringCycle"
                disabled
                :min="1"
                style="width: 100%"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="检测启用状态">
              <el-select
                v-model="form.monitoringState"
                placeholder=""
                disabled
                style="width: 100%"
              >
                <el-option
                  v-for="item in dict.type.status_disable"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="单位地址">
              <el-input v-model="form.organizationAddress" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="佩戴开始日期">
              <el-date-picker
                style="width: 100%"
                v-model="form.wearingBeginTime"
                value-format="yyyy-MM-dd HH:mm:ss"
                type="date"
                :picker-options="pickerOptionsF"
                placeholder="请选择"
                clearable
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="佩戴结束日期">
              <el-date-picker
                style="width: 100%"
                v-model="form.wearingEndTime"
                value-format="yyyy-MM-dd HH:mm:ss"
                type="date"
                :picker-options="pickerOptionsS"
                placeholder="请选择"
                clearable
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <div ref="printcontainer">
        <div v-for="(item, index) in printList" :key="index" class="printmy">
          <div style="width: 16mm; line-height: 5.5mm">
            <div style="height: 5mm; font-size: 12px">
              {{ item.name }}
            </div>
            <div style="height: 5mm">
              {{ item.entrustDeptName ? item.entrustDeptName : " " }}
            </div>
            <div style="height: 5mm">
              {{ item.dosageType == "0" ? "正常" : "" }}
              {{ item.dosageType == "1" ? "铅衣内" : "" }}
              {{ item.dosageType == "2" ? "铅衣外" : "" }}
              {{ item.dosageType == "3" ? "本底" : "" }}
            </div>
          </div>
          <div style="height: 5mm; position: absolute; bottom: 3mm">
            佩戴时间：{{ item.wearingBeginTime.slice(0, 10) }} ~
            {{ item.wearingEndTime.slice(0, 10) }}
          </div>
          <svg class="barcode" :id="`barcode${index}`"></svg>
        </div>
      </div>

      <el-table
        class="handletabel"
        v-loading="loadingAdd"
        :data="form.taskPersonalDosimeterResultList"
        height="403"
      >
        <el-table-column
          label="人员编号"
          align="center"
          prop="personnelNumber"
          width="100"
        />
        <el-table-column
          label="剂量计编号"
          align="center"
          prop="dosageNumber"
          width="150"
        />
        <el-table-column
          label="姓名"
          align="center"
          prop="personnelName"
          width="130"
        >
          <template slot-scope="scope">
            <span>{{ scope.row.personnelName }}</span>
            <span v-if="scope.row.dosageType == 1">(内)</span>
            <span v-if="scope.row.dosageType == 2">(外)</span>
          </template>
        </el-table-column>
        <el-table-column label="性别" align="center" width="60">
          <template slot-scope="scope">
            <dict-tag
              :value="scope.row.personnelSex"
              :options="dict.type.sys_user_sex"
            ></dict-tag>
          </template>
        </el-table-column>
        <el-table-column label="职业分类" align="center">
          <template slot-scope="scope">
            <dict-tag
              :value="scope.row.occupationalClassification"
              :options="dict.type.occupational_classification"
            ></dict-tag>
          </template>
        </el-table-column>
        <el-table-column label="身份证号" align="center" prop="idCard" />
        <el-table-column label="剂量计佩戴起止日期" align="center">
          <template slot-scope="{ row }">
            {{ parseTime(row.wearingBeginTime, "{y}/{m}/{d}") }} -
            {{ parseTime(row.wearingEndTime, "{y}/{m}/{d}") }}
          </template>
        </el-table-column>
        <el-table-column align="center" width="100" label="操作">
          <template slot-scope="scope">
            <el-button
              @click.native.prevent="deleteData(scope.row, scope.$index)"
              type="text"
              style="color: #f32d2d"
            >
              删除
            </el-button>
          </template>
        </el-table-column>
      </el-table>

      <pagination
        style="margin-bottom: 5px"
        v-show="totalAdd > 0"
        :total="totalAdd"
        :page.sync="queryParamsAdd.pageNum"
        :limit.sync="queryParamsAdd.pageSize"
        @pagination="getListAdd"
      />

      <div slot="footer">
        <el-button type="primary" v-if="status != '3'" @click="submitForm"
          >确 定</el-button
        >
        <el-button @click="dialogVisible = false">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 办理弹框 -->
    <el-dialog
      :title="bltitle"
      :visible.sync="dialogVisiblehandle"
      :close-on-click-modal="false"
      width="1500px"
      class="bldialog"
      v-dialogDrag="true"
    >
      <el-form
        class="handleform"
        :disabled="blstatus != '1'"
        :model="handleform"
        size="small"
        label-width="100px"
      >
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="单位名称">
              <el-input v-model="handleform.organizationName" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="合同编号">
              <el-input
                v-if="handleform.agreementNumber"
                v-model="handleform.agreementNumber"
                disabled
              ></el-input>
              <el-select
                v-else
                v-model="handleform.agreementNumber"
                :placeholder="blstatus == '1' ? '请选择' : ''"
                style="width: 100%"
                clearable
              >
                <el-option
                  :label="item.agreementNumber"
                  :value="item.agreementNumber"
                  v-for="(item, index) in agreementList"
                  :key="index"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="联系人">
              <el-input v-model="handleform.contactsName" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="联系电话">
              <el-input v-model="handleform.contactsMobile" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="检测周期(天)">
              <el-input-number
                v-model="handleform.monitoringCycle"
                disabled
                :min="1"
                style="width: 100%"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="检测启用状态">
              <el-select
                v-model="handleform.monitoringState"
                disabled
                style="width: 100%"
              >
                <el-option
                  v-for="item in dict.type.status_disable"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="单位地址">
              <el-input v-model="handleform.organizationAddress" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="佩戴开始日期">
              <el-date-picker
                style="width: 100%"
                v-model="handleform.wearingBeginTime"
                value-format="yyyy-MM-dd HH:mm:ss"
                type="date"
                :picker-options="pickerOptionsHandleF"
                placeholder="请选择"
                clearable
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="佩戴结束日期">
              <el-date-picker
                style="width: 100%"
                v-model="handleform.wearingEndTime"
                value-format="yyyy-MM-dd HH:mm:ss"
                type="date"
                :picker-options="pickerOptionsHandleS"
                placeholder="请选择"
                clearable
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <div class="separate"></div>
      <el-form
        class="handleform"
        @submit.native.prevent
        :model="queryParamsHandle"
        size="small"
        label-width="100px"
      >
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="关键词">
              <el-input
                v-model="queryParamsHandle.searchStr"
                placeholder="请输入人员编号、剂量计编号或人员姓名"
                clearable
                @clear="getListHandle()"
                @keyup.enter.native="getListHandle()"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label-width="20px">
              <el-button
                type="primary"
                icon="el-icon-search"
                size="mini"
                @click="getListHandle()"
                >查询</el-button
              >
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <div class="opration">
        <div class="filelist">
          报告文件：
          <span
            class="filelistitem"
            v-for="(item, index) in fileList"
            :key="index"
            @click="viewFile(item)"
          >
            {{ item.originalName }}
          </span>
        </div>
        <el-button
          type="primary"
          v-if="blstatus == '1' || blstatus == '2'"
          class="print blreport"
          size="mini"
          @click="launch(0)"
          >保 存</el-button
        >
        <el-button
          v-if="blstatus == '1'"
          class="print blreport"
          type="primary"
          size="mini"
          @click.native.prevent="editTrackingNumber()"
          >修改快递单号</el-button
        >
        <el-button
          v-if="blstatus == '1'"
          class="print blreport"
          type="primary"
          size="mini"
          icon="el-icon-plus"
          @click.native.prevent="addLine()"
          >添加人员</el-button
        >
        <el-button
          :loading="loadingReport"
          v-if="blstatus == '1'"
          class="print blreport"
          type="primary"
          :disabled="!handleform.list || handleform.list.length == 0"
          size="mini"
          @click.native.prevent="handleReport()"
        >
          <span v-if="!loadingReport">生成报告</span>
          <span v-else>生成中...</span>
        </el-button>
        <el-button
          v-if="blstatus == '1'"
          class="print blprint"
          type="primary"
          :disabled="!handleform.list || handleform.list.length == 0"
          size="mini"
          @click.native.prevent="handlePrint()"
          >打印编号</el-button
        >
      </div>
      <el-table
        class="handletabel"
        ref="tableData"
        :class="blstatus == '2' && 'handletabelaudit'"
        v-loading="loadingHandle"
        :data="handleform.list"
        :row-class-name="tableRowClassName"
        :cell-class-name="tableCellClassName"
        @selection-change="handleSelectionChange"
        height="364"
        @row-dblclick="dbclick"
      >
        <!-- <el-table-column type="selection" align="center" width="50" /> -->
        <el-table-column
          label="人员编号"
          align="center"
          prop="personnelNumber"
          width="100"
        />
        <el-table-column
          label="剂量计编号"
          align="center"
          prop="dosageNumber"
          width="130"
        />
        <el-table-column label="姓名" align="center" width="100">
          <template slot-scope="scope">
            <!--v-if去判断双击的是不是当前单元格-->
            <el-input
              @blur="hideInput(scope.row)"
              size="mini"
              :ref="scope.row.index + ',' + scope.column.index"
              v-model="scope.row.personnelName"
              v-if="
                scope.row.index + ',' + scope.column.index == currentCell &&
                !scope.row.isadd
              "
            >
            </el-input>

            <!--v-if去判断双击的是不是当前单元格-->
            <el-select
              @change="changeUnhandledPerson($event, scope.row)"
              size="mini"
              :ref="scope.row.index + ',' + scope.column.index"
              v-model="scope.row.showTypeName"
              v-if="
                scope.row.index + ',' + scope.column.index == currentCell &&
                scope.row.isadd
              "
              class="selectperson"
              style="width: 100%"
            >
              <el-option
                v-for="item in unHandleWorkPersonnelList"
                :key="item.dosageNumber"
                :label="
                  item.personnelName +
                  (item.dosageType == '1'
                    ? '(内)'
                    : item.dosageType == '2'
                    ? '(外)'
                    : '')
                "
                :value="
                  item.personnelName +
                  (item.dosageType == '1'
                    ? '(内)'
                    : item.dosageType == '2'
                    ? '(外)'
                    : '')
                "
              >
              </el-option>
            </el-select>

            <span
              v-if="scope.row.index + ',' + scope.column.index != currentCell"
            >
              <span>{{ scope.row.personnelName }}</span>
              <span v-if="scope.row.dosageType == 1">(内)</span>
              <span v-if="scope.row.dosageType == 2">(外)</span>
            </span>
          </template>
        </el-table-column>
        <el-table-column label="性别" align="center" width="100">
          <template slot-scope="scope">
            <!--v-if去判断双击的是不是当前单元格-->
            <el-select
              @change="hideInput(scope.row)"
              size="mini"
              :ref="scope.row.index + ',' + scope.column.index"
              v-model="scope.row.personnelSex"
              v-if="
                scope.row.index + ',' + scope.column.index == currentCell &&
                !scope.row.isadd
              "
              style="width: 100%"
            >
              <el-option
                v-for="item in dict.type.sys_user_sex"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>

            <dict-tag
              v-else
              :value="scope.row.personnelSex"
              :options="dict.type.sys_user_sex"
            ></dict-tag>
          </template>
        </el-table-column>
        <el-table-column label="职业类别" align="center" width="150">
          <template slot-scope="scope">
            <!--v-if去判断双击的是不是当前单元格-->
            <el-select
              @change="hideInput(scope.row)"
              size="mini"
              :ref="scope.row.index + ',' + scope.column.index"
              v-model="scope.row.occupationalClassification"
              v-if="
                scope.row.index + ',' + scope.column.index == currentCell &&
                !scope.row.isadd
              "
              style="width: 100%"
            >
              <el-option
                v-for="item in dict.type.occupational_classification"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>

            <dict-tag
              v-else
              :value="scope.row.occupationalClassification"
              :options="dict.type.occupational_classification"
            ></dict-tag>
          </template>
        </el-table-column>
        <el-table-column label="剂量计佩戴起止日期" align="center" width="250">
          <template slot-scope="scope">
            <span
              v-if="
                scope.row.index + ',' + scope.column.index == currentCell &&
                !scope.row.isadd
              "
            >
              <el-date-picker
                @blur="hideInput(scope.row)"
                size="mini"
                :ref="scope.row.index + ',' + scope.column.index"
                v-model="scope.row.wearingBeginTime"
                class="wearingedit"
                style="width: 43%"
                value-format="yyyy-MM-dd HH:mm:ss"
                type="date"
                :picker-options="pickerOptionsHandleEdit"
                :clearable="false"
              >
              </el-date-picker>
              -
              {{ parseTime(scope.row.wearingEndTime, "{y}/{m}/{d}") }}
            </span>

            <span v-else>
              {{ parseTime(scope.row.wearingBeginTime, "{y}/{m}/{d}") }} -
              {{ parseTime(scope.row.wearingEndTime, "{y}/{m}/{d}") }}
            </span>
          </template>
        </el-table-column>
        <!-- <el-table-column label="寄出单号" align="center" prop="sendTrackingNumber" :width="blstatus != '3' && 150">
						<template slot-scope="scope">
							<el-input
								v-if="scope.row.index + ',' + scope.column.index == currentCell && !scope.row.isadd && scope.row.isEmptyTrackingNumber"
								@blur="hideInput(scope.row)"
								size="mini"
								:ref="scope.row.index + ',' + scope.column.index"
								v-model="scope.row.sendTrackingNumber">
							</el-input>

							<span v-else>
								<span>{{scope.row.sendTrackingNumber}}</span>
							</span>
						</template>
					</el-table-column> -->
        <el-table-column
          label="剂量当量1"
          align="center"
          prop="holeOneDosageValue"
          width="150"
        />
        <el-table-column
          label="剂量当量2"
          align="center"
          prop="holeTwoDosageValue"
          width="150"
        />
        <el-table-column
          label="剂量当量(mSv)"
          align="center"
          prop="dosageValue"
          width="120"
        />
        <el-table-column label="操作" align="center" v-if="blstatus != '3'">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              style="color: #f32d2d"
              @click="deleteItem(scope.$index)"
              v-if="!scope.row.sendTrackingNumber"
              >删除</el-button
            >
            <el-button
              size="mini"
              type="text"
              @click="handleException(scope.row)"
              v-if="largeDose && scope.row.dosageValue > largeDose"
              >异常报备</el-button
            >
          </template>
        </el-table-column>
      </el-table>

      <pagination
        style="margin-bottom: 5px"
        v-show="totalHandle > 0"
        :total="totalHandle"
        :page.sync="queryParamsHandle.pageNum"
        :limit.sync="queryParamsHandle.pageSize"
        @pagination="getListHandle"
      />

      <div slot="footer">
        <el-button
          type="primary"
          v-if="blstatus == '1' || blstatus == '2'"
          class="blbtn"
          @click="launch(1)"
          >办 理</el-button
        >
        <el-button
          type="danger"
          v-if="blstatus == '2'"
          class="blbtn"
          @click="launch(2)"
          >驳 回</el-button
        >
        <el-button
          v-if="blstatus == '1' || blstatus == '3'"
          @click="dialogVisiblehandle = false"
          >关 闭</el-button
        >
      </div>
    </el-dialog>

    <!-- 修改快递单号弹框 -->
    <el-dialog
      title="修改快递单号"
      :visible.sync="editTrackingNumberVisible"
      :close-on-click-modal="false"
      width="600px"
      v-dialogDrag="true"
    >
      <el-form
        class="seachform"
        :model="editTrackingNumberForm"
        :rules="rulesTracking"
        ref="editTrackingNumberForm"
        size="small"
        label-width="120px"
      >
        <el-row>
          <el-col :span="20">
            <el-form-item label="快递单号" prop="sendTrackingNumber">
              <el-input
                v-model="editTrackingNumberForm.sendTrackingNumber"
                placeholder="请输入"
                clearable
              />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer">
        <el-button type="primary" @click="submitTrackingNumber"
          >确 定</el-button
        >
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  personalDosimeterList,
  personalDosimeterDetail,
  personalDosimeterEdit,
  personalDosimeterAdd,
  getHandleData,
  personalDosimeterHandle,
  personalDosimeterProcess,
  generateReport,
  getWorkingPersonnelByOrganizationId,
  personalDosimeterRemove,
  getUnHandleWorkPersonnelList,
  addSendTrackingNumber,
} from "@/api/slides/task";
import {
  personalDosimeterReportList,
  detectionEquipmentReportList,
} from "@/api/report/report";
import {
  addExceptionalRecord,
  getConfiglargeDose,
} from "@/api/slides/abnormal";
import { getAgreementListWithTaskDosimeter } from "@/api/person/entrustAgreement";
import { entrustOrganizationListing } from "@/api/person/entrustOrganization";
import { listOss, listByIds, delOss } from "@/api/system/oss";
import { getLodop, needCLodop } from "@/utils/LodopFuncs.js";

export default {
  name: "User",
  dicts: [
    "sys_user_sex",
    "occupational_classification",
    "person_report_status",
  ],
  data() {
    return {
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      total: 0,
      dialogVisible: false,
      // 表单参数
      form: {},
      loading: false,
      status: null,
      title: null,
      loadingReport: false,
      rules: {
        entrustOrganizationId: [
          { required: true, message: "单位名称不能为空", trigger: "blur" },
        ],
      },
      // 委托单位下拉框
      entrustOrganizationSelect: [],
      activeName: "-4",
      // 外照射任务列表
      personalDosimeterReportList: [],
      // 办理弹框
      dialogVisiblehandle: false,
      handleStatus: null,
      handleform: {},
      blstatus: null,
      bltitle: null,
      // 删除的人员
      deletePerson: [],
      // 合同下拉框
      agreementList: [],
      tableList: [], // 打印的标签集合
      nubId: [], // 标签顶部的条形码数据
      printOptions: [], // 打印机数据
      printType: "", // label1 -> 4*6; A4 -> A4
      LODOP: null,
      printList: [],
      // 办理的查询参数
      queryParamsHandle: {
        pageNum: 1,
        pageSize: 10,
        searchStr: "",
      },
      totalHandle: 0,
      // 打开的当行id
      handleId: null,
      loadingHandle: false,
      // 添加的查询参数
      queryParamsAdd: {
        pageNum: 1,
        pageSize: 10,
      },
      totalAdd: 0,
      // 打开的当行id
      addId: null,
      loadingAdd: false,
      // 流程信息
      height: document.documentElement.clientHeight - 205 + "px;",
      isPer: false,
      isHide: false,
      // 日期校验
      pickerOptionsF: {
        disabledDate: (time) => {
          return time.getTime() > new Date(this.form.wearingEndTime).getTime();
        },
      },
      pickerOptionsS: {
        disabledDate: (time) => {
          return (
            time.getTime() < new Date(this.form.wearingBeginTime).getTime()
          );
        },
      },
      pickerOptionsHandleF: {
        disabledDate: (time) => {
          return (
            time.getTime() > new Date(this.handleform.wearingEndTime).getTime()
          );
        },
      },
      pickerOptionsHandleS: {
        disabledDate: (time) => {
          return (
            time.getTime() <
            new Date(this.handleform.wearingBeginTime).getTime()
          );
        },
      },
      pickerOptionsHandleEdit: {
        disabledDate: (time) => {
          return (
            time.getTime() > new Date(this.handleform.wearingEndTime).getTime()
          );
        },
      },
      // 生成的报告列表
      fileList: [],
      // 勾选的打印列表
      selected: [],
      // 双击索引
      currentCell: null,
      // 未办理人员列表添行
      unHandleWorkPersonnelList: [],
      // 视图高度
      height: document.documentElement.clientHeight,
      // 修改快递单号
      editTrackingNumberVisible: false,
      editTrackingNumberForm: {},
      rulesTracking: {
        sendTrackingNumber: [
          { required: true, message: "快递单号不能为空", trigger: "blur" },
        ],
      },
      // 大剂量标准值
      largeDose: null,
    };
  },
  inject: ["getAppLoading"],
  computed: {
    app_loading() {
      return this.getAppLoading();
    },
  },
  created() {
    this.getList();
    // 获取大剂量标准值
    this.configlargeDose();
  },
  methods: {
    // 切换tab栏
    changeTab(tab, event) {
      this.queryParams.tasksState = tab.name;
      this.personalDosimeterReportList = [];
      this.getList();
    },
    // 获取外照射任务列表
    getList() {
      this.loading = true;
      personalDosimeterReportList(this.queryParams)
        .then((response) => {
          this.personalDosimeterReportList = response.rows;
          this.total = response.total;
          this.loading = false;
        })
        .catch((response) => {
          this.loading = false;
        });
    },
    // 获取委托单位下拉框
    getEntrustOrganizationListing() {
      entrustOrganizationListing().then((response) => {
        this.entrustOrganizationSelect = response.data;
      });
    },
    // 获取大剂量标准值
    configlargeDose() {
      getConfiglargeDose().then((response) => {
        this.largeDose = response.msg;
      });
    },
    // 列表标红
    tableRowClassName({ row, rowIndex }) {
      if (this.largeDose && row.dosageValue > this.largeDose) {
        return "warning-row";
      }
      return "";
    },
    // 下载报告
    downloadReport(ossId) {
      listByIds(ossId).then((response) => {
        let lastIndex = response.data[0].url.lastIndexOf(".");
        let suffix = response.data[0].url.substring(lastIndex + 1);
        console.log("后缀", suffix);
        let data = {
          url: response.data[0].url,
          name: response.data[0].originalName,
          type: suffix,
        };
        fetch(data.url, {
          method: "get",
          mode: "cors",
        })
          .then((response) => response.blob())
          .then((res) => {
            const downloadUrl = window.URL.createObjectURL(
              //new Blob() 对后端返回文件流类型处理
              new Blob([res], {
                type:
                  data.type == "pdf"
                    ? "application/pdf"
                    : data.type == "docx"
                    ? "application/msword"
                    : data.type == "xlsx"
                    ? "application/vnd.ms-excel"
                    : "",
              })
            );
            //word文档为msword,pdf文档为pdf
            const link = document.createElement("a");
            link.href = downloadUrl;
            link.setAttribute("download", data.name);
            document.body.appendChild(link);
            link.click();
            link.remove();
          })
          .catch((error) => {
            window.open(data.url);
          });
      });
    },
    // 提交任务
    submitForm() {
      console.log("this.form.formDate", this.form.formDate);
      this.$refs["form"].validate((valid) => {
        if (!valid) return;
        let deleteIds = this.deletePerson.map((item) => {
          return {
            id: item.taskPersonalResultId,
            dosageType: item.dosageType,
          };
        });
        if (this.status == "1") {
          let form = {
            entrustOrganizationId: this.form.entrustOrganizationId,
            agreementId: this.form.agreementId,
            wearingBeginTime: this.form.wearingBeginTime,
            wearingEndTime: this.form.wearingEndTime,
            deleteItems: deleteIds,
          };
          personalDosimeterAdd(form).then((response) => {
            this.$modal.msgSuccess("新增成功");
            this.dialogVisible = false;
            this.getList();
          });
        } else if (this.status == "2") {
        }
      });
    },
    // 打开办理对话框
    openhandleDialog(row, status) {
      this.handleform = {};
      this.fileList = [];
      this.selected = [];
      this.currentCell = null;
      this.handleStatus = status;
      this.handleform.taskPersonalDosimeterId = row.taskPersonalDosimeterId;

      if (status == "1") {
        if (this.activeName == "1") {
          this.blstatus = "2";
        } else {
          this.blstatus = "1";
        }
        this.bltitle = "办理";
      }
      if (status == "3") {
        this.blstatus = "3";
        this.bltitle = "查看外照射任务";
      }
      console.log("this.blstatus", this.blstatus);
      personalDosimeterDetail(row.taskPersonalDosimeterId).then((response) => {
        if (response.data) {
          if (response.data.monitoringState != null) {
            response.data.monitoringState =
              response.data.monitoringState.toString();
          }
          this.handleform = response.data;
          this.handleform.operationList = [];
          if (response.data.entrustOrganizationId && status == "1") {
            getAgreementListWithTaskDosimeter({
              entrustOrganizationId: response.data.entrustOrganizationId,
            }).then((response) => {
              this.agreementList = response.data;
            });
          }
          if (response.data.ossId) {
            listByIds(response.data.ossId).then((response) => {
              this.fileList = response.data.map((item) => {
                return {
                  url: item.url,
                  originalName: item.originalName,
                };
              });
            });
          }
          this.handleId = row.taskPersonalDosimeterId;
          this.queryParamsHandle = {
            pageNum: 1,
            pageSize: 10,
            searchStr: "",
          };
          this.getListHandle();
          this.dialogVisiblehandle = true;
        }
      });
      // // 获取未办理人员下拉框
      // getUnHandleWorkPersonnelList(row.taskPersonalDosimeterId).then((response) => {
      // 	if(response.data && response.data.length != 0) {
      // 		this.unHandleWorkPersonnelList = response.data;
      // 		this.unHandleWorkPersonnelList.forEach(item => {
      // 			item.showTypeName = item.personnelName + (item.dosageType == '1' ? '(内)' : item.dosageType == '2' ? '(外)' : '');
      // 			item.originName = item.personnelName;
      // 			item.isEmptyTrackingNumber = !item.sendTrackingNumber;
      // 		})
      // 	}
      // });
    },
    // 分页获取人员（根据row.taskPersonalDosimeterId）
    getListHandle() {
      this.queryParamsHandle.id = this.handleId;
      this.loadingHandle = true;
      getHandleData(this.queryParamsHandle)
        .then((response) => {
          this.handleform.list = response.rows || [];
          if (this.handleform.list.length != 0) {
            this.handleform.list.forEach((item) => {
              item.showTypeName =
                item.personnelName +
                (item.dosageType == "1"
                  ? "(内)"
                  : item.dosageType == "2"
                  ? "(外)"
                  : "");
              item.originName = item.personnelName;
              item.isEmptyTrackingNumber = !item.sendTrackingNumber;
            });
          }
          this.totalHandle = response.total;
          this.loadingHandle = false;
        })
        .catch((response) => {
          this.loadingHandle = false;
        });
    },
    // 分页获取人员（添加时根据单位id）
    getListAdd() {
      this.queryParamsAdd.entrustOrganizationId = this.addId;
      this.loadingAdd = true;
      getWorkingPersonnelByOrganizationId(this.queryParamsAdd)
        .then((response) => {
          this.form.taskPersonalDosimeterResultList = response.rows;
          if (this.form.taskPersonalDosimeterResultList.length != 0) {
            let obj = this.form.taskPersonalDosimeterResultList[0];
            if (obj.wearingBeginTime) {
              this.$set(this.form, "wearingBeginTime", obj.wearingBeginTime);
            }
            if (obj.wearingEndTime) {
              this.$set(this.form, "wearingEndTime", obj.wearingEndTime);
            }
          }
          this.totalAdd = response.total;
          this.loadingAdd = false;
        })
        .catch((response) => {
          this.loadingAdd = false;
        });
    },
    // 提交办理/保存
    launch(type) {
      // console.log("this.handleform.operationList", this.handleform.operationList);
      let form = {
        id: this.handleform.taskPersonalDosimeterId,
        wearingBeginTime: this.handleform.wearingBeginTime,
        wearingEndTime: this.handleform.wearingEndTime,
        agreementId: this.handleform.agreementId,
        operation: type,
        operationList: this.handleform.operationList,
      };
      // console.log("this.handleform.list", this.handleform.list);
      personalDosimeterHandle(form).then((response) => {
        if (type == 1) {
          this.dialogVisiblehandle = false;
          this.getList();
          this.$modal.msgSuccess("操作成功");
        } else {
          this.getListHandle();
          this.$modal.msgSuccess("保存成功");
        }
      });
    },
    // 生成报告
    handleReport() {
      this.loadingReport = true;
      generateReport(this.handleform.taskPersonalDosimeterId)
        .then((response) => {
          this.loadingReport = false;
          if (response.msg) {
            /* 错误 */
            this.$alert(
              "<div style='overflow: auto; max-height: 70vh; padding: 0 20px 0; margin-top: -20px;'>" +
                response.msg +
                "</div>",
              "生成失败",
              { dangerouslyUseHTMLString: true }
            );
          } else {
            if (response.data) {
              this.$alert(
                "<div style='overflow: auto; max-height: 70vh; padding: 0 20px 0; font-size: 16px'>" +
                  "生成成功！" +
                  "</div>",
                "",
                { dangerouslyUseHTMLString: true }
              );
              listByIds(response.data).then((response) => {
                this.fileList = response.data.map((item) => {
                  return {
                    url: item.url,
                    originalName: item.originalName,
                  };
                });
                console.log("this.filelist", this.fileList);
              });
            }
          }
        })
        .catch(() => {
          this.loadingReport = false;
        });
    },
    // 报告预览
    viewFile(item) {
      // fetch(item.url, {
      // 		method: "get",
      // 		mode: "cors",
      // 	})
      // 	.then((response) => response.blob())
      // 	.then((res) => {
      // 		const downloadUrl = window.URL.createObjectURL(
      // 			//new Blob() 对后端返回文件流类型处理
      // 			new Blob([res], {
      // 				type: "application/pdf"
      // 			})
      // 		);
      // 		//word文档为msword,pdf文档为pdf
      // 		const link = document.createElement("a");
      // 		link.href = downloadUrl;
      // 		link.setAttribute("download", item.originalName);
      // 		document.body.appendChild(link);
      // 		link.click();
      // 		link.remove();
      // 	}).catch((error) => {
      // 		window.open(item.url);
      // 	});
      if (item?.url) {
        window.open(item.url, "PDF", "");
      } else {
        this.$modal.msgWarning("暂无文件");
      }
    },
    // 更改单位（添加时）
    changeEntrustOrganizationId(val) {
      this.addId = val;
      let obj = this.entrustOrganizationSelect.find((item) => {
        return item.entrustOrganizationId == val;
      });
      if (!obj) {
        this.form = {
          taskPersonalDosimeterResultList: [],
        };
        this.agreementList = [];
        return;
      }
      this.$set(this.form, "contactsName", obj.contactsName);
      this.$set(this.form, "contactsMobile", obj.contactsMobile);
      this.$set(this.form, "monitoringCycle", obj.monitoringCycle);
      this.$set(this.form, "monitoringState", obj.monitoringState);
      this.$set(this.form, "organizationAddress", obj.addressDetails);
      this.$set(this.form, "formDate", null);
      getAgreementListWithTaskDosimeter({ entrustOrganizationId: val }).then(
        (response) => {
          this.agreementList = response.data;
        }
      );
      this.getListAdd();
    },
    // 删除
    handleDelete(row) {
      this.$modal
        .confirm(`是否确认删除任务 [${row.agreementNumber}]？`)
        .then(() => {
          this.loading = true;
          return personalDosimeterRemove(row.taskPersonalDosimeterId);
        })
        .then(() => {
          this.loading = false;
          this.$modal.msgSuccess("删除成功");
          this.getList();
        })
        .finally(() => {
          this.loading = false;
        });
    },
    deleteData(row, index) {
      console.log("删除索引", index);
      this.$modal.confirm(`是否确认删除该数据？`).then(() => {
        this.deletePerson.push(row);
        this.form.taskPersonalDosimeterResultList.splice(index, 1);
      });
    },
    // 查询重置
    reset() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 10,
      };
      this.resetForm("queryParams");
      this.getList();
    },
    // 更改打印勾选
    handleSelectionChange(selection) {
      this.selected = selection;
    },
    // 打印编号
    handlePrint() {
      let printList = [];
      if (this.selected.length == 0) {
        printList = JSON.parse(JSON.stringify(this.handleform.list));
      } else {
        printList = this.selected;
      }
      if (needCLodop()) {
        try {
          let LODOP = getLodop();
          console.log("LODOP", LODOP);

          console.log("---------", LODOP.GET_PRINTER_NAME(0));
          console.log("---------", LODOP.GET_PRINTER_NAME(1));
          console.log("---------", LODOP.GET_PRINTER_COUNT());
          console.log(
            "---------PaperLength",
            LODOP.GET_PRINTER_NAME("0:PaperLength")
          );
          console.log(
            "---------PaperWidth",
            LODOP.GET_PRINTER_NAME("0:PaperWidth")
          );
          console.log(
            "---------MaxExtentWidth",
            LODOP.GET_PRINTER_NAME("0:MaxExtentWidth")
          );
          console.log(
            "---------PaperSize",
            LODOP.GET_PRINTER_NAME("0:PaperSize")
          );
          console.log(
            "---------PortName",
            LODOP.GET_PRINTER_NAME("0:PortName")
          );
          console.log(
            "---------MinExtentWidth",
            LODOP.GET_PRINTER_NAME("0:MinExtentWidth")
          );
          console.log("---------Copies", LODOP.GET_PRINTER_NAME("0:Copies"));
          // console.log("---------", LODOP.GET_PRINTER_NAME("1:MaxExtentWidth"));
          this.loading = true;
          if (false) {
            /* 佳博打印机 */
            printList.forEach((item, index) => {
              let isodd = index % 2 == 1;
              let offset = isodd ? 35 + 2 : 0;
              LODOP.SET_PRINT_PAGESIZE(1, `${3.5 + 3.5 + 0.2}cm`, `${2}cm`, "");
              // LODOP.SET_PRINT_PAGESIZE(1, "1000mm", "1000mm","");
              // LODOP.SET_PRINT_PAGESIZE(1);
              // LODOP.SET_PRINT_PAGESIZE(2, 0, 0,"A4");
              // let line = Math.ceil(item.personnelName.length / 5);
              // let offsetOri = 1.6 * (line-1); /* 部门和剂量计偏移量 */
              let offsetOri = 0; /* 部门和剂量计偏移量 */
              LODOP.ADD_PRINT_TEXT(
                "2mm",
                `${2 + offset}mm`,
                "100%",
                "100%",
                item.personnelName
              );
              LODOP.SET_PRINT_STYLEA(0, "FontSize", 8);
              LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
              // 部门-------------------------------------
              LODOP.ADD_PRINT_TEXT(
                `${6 + offsetOri}mm`,
                `${2 + offset}mm`,
                "100%",
                "100%",
                item.entrustDeptName
              );
              LODOP.SET_PRINT_STYLEA(0, "FontSize", 6);
              LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
              // 铅衣
              if (item.personnelName == "环境对照") {
                LODOP.ADD_PRINT_TEXT(
                  `${10 + offsetOri}mm`,
                  `${2 + offset}mm`,
                  "100%",
                  "100%",
                  ""
                );
              } else {
                LODOP.ADD_PRINT_TEXT(
                  `${10 + offsetOri}mm`,
                  `${2 + offset}mm`,
                  "100%",
                  "100%",
                  `${
                    item.dosageType == "1"
                      ? "铅衣内"
                      : item.dosageType == "2"
                      ? "铅衣外"
                      : item.dosageType == "3"
                      ? "本底"
                      : ""
                  }`
                );
              }
              LODOP.SET_PRINT_STYLEA(0, "FontSize", 6);
              LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
              // 剂量计------------------------------------
              LODOP.ADD_PRINT_TEXT(
                `${13 + offsetOri}mm`,
                `${2 + offset}mm`,
                "100%",
                "100%",
                item.dosageNumber
              );
              LODOP.SET_PRINT_STYLEA(0, "FontSize", 6);
              LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
              // 时间------------------------------------
              LODOP.ADD_PRINT_TEXT(
                `${16}mm`,
                `${2 + offset}mm`,
                "100%",
                "100%",
                `${this.parseTime(
                  item.wearingBeginTime,
                  "{y}/{m}/{d}"
                )}-${this.parseTime(item.wearingEndTime, "{y}/{m}/{d}")}`
              );
              LODOP.SET_PRINT_STYLEA(0, "FontSize", 5);
              LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
              // 二维码---------------------------------------------
              // LODOP.ADD_PRINT_BARCODE("2mm", `${13 + offset}mm`, "2.1cm", "1.1cm", "128A", item.dosageNumber);
              LODOP.ADD_PRINT_BARCODE(
                "6mm",
                `${22 + offset}mm`,
                "1.5cm",
                "1.5cm",
                "QRCode",
                item.dosageNumber + "-" + item.batchNum
              );
              LODOP.SET_PRINT_MODE("Full-Page");
              // LODOP.SET_PRINT_STYLEA(0, "Stretch", 2);//按原图比例(不变形)缩放模式
              // LODOP.SET_PRINT_STYLEA(0, "Bold" , 0);
              // LODOP.SET_PRINT_STYLEA(0, "FontSize", 6);
              // LODOP.SET_PRINT_STYLEA(0, "AlignJustify", 2);//设置条码下方的文字相对于条码本身居中

              if (index != printList.length - 1 && isodd) {
                LODOP.NEWPAGE();
              }
            });
          }
          if (true) {
            /* 演示-芯烨打印机 */
            printList.forEach((item, index) => {
              LODOP.SET_PRINT_PAGESIZE(1, `3.8cm`, `3.2cm`, "");
              let offset = 0; /* 水平便宜量 */
              let offsetOri = 5; /* 垂直偏移量 */
              // 姓名------------------------------------
              LODOP.ADD_PRINT_TEXT(
                `${0 + offsetOri}mm`,
                `${2 + offset}mm`,
                "100%",
                "100%",
                item.personnelName || ""
              );
              LODOP.SET_PRINT_STYLEA(0, "FontSize", 10);
              LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
              // 部门-------------------------------------
              LODOP.ADD_PRINT_TEXT(
                `${6 + offsetOri}mm`,
                `${2 + offset}mm`,
                "100%",
                "100%",
                item.entrustDeptName || ""
              );
              LODOP.SET_PRINT_STYLEA(0, "FontSize", 8);
              LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
              // 铅衣--------------------------------------
              if (item.personnelName == "环境对照") {
                LODOP.ADD_PRINT_TEXT(
                  `${11 + offsetOri}mm`,
                  `${2 + offset}mm`,
                  "100%",
                  "100%",
                  ""
                );
              } else {
                LODOP.ADD_PRINT_TEXT(
                  `${11 + offsetOri}mm`,
                  `${2 + offset}mm`,
                  "100%",
                  "100%",
                  `${
                    item.dosageType == "1"
                      ? "铅衣内"
                      : item.dosageType == "2"
                      ? "铅衣外"
                      : item.dosageType == "3"
                      ? "本底"
                      : ""
                  }`
                );
              }
              LODOP.SET_PRINT_STYLEA(0, "FontSize", 8);
              LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
              // 剂量计------------------------------------
              LODOP.ADD_PRINT_TEXT(
                `${16 + offsetOri}mm`,
                `${2 + offset}mm`,
                "100%",
                "100%",
                item.dosageNumber || ""
              );
              LODOP.SET_PRINT_STYLEA(0, "FontSize", 8);
              LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
              // 时间------------------------------------
              LODOP.ADD_PRINT_TEXT(
                `${20 + offsetOri}mm`,
                `${2 + offset}mm`,
                "100%",
                "100%",
                `${this.parseTime(
                  item.wearingBeginTime,
                  "{y}/{m}/{d}"
                )}-${this.parseTime(item.wearingEndTime, "{y}/{m}/{d}")}`
              );
              LODOP.SET_PRINT_STYLEA(0, "FontSize", 6);
              LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
              // 二维码---------------------------------------------
              LODOP.ADD_PRINT_BARCODE(
                `${2 + offsetOri}mm`,
                `${20 + offset}mm`,
                "1.85cm",
                "1.85cm",
                "QRCode",
                item.dosageNumber + "-" + item.batchNum
              );
              if (index != printList.length - 1) {
                LODOP.NEWPAGE();
              }
            });
          }
          LODOP.PRINT();
          // LODOP.PREVIEW();
          this.loading = false;
        } catch (error) {
          console.log("error", error);
          this.$alert(
            `检测到您还未安装C-LODOP套打控件,请确认启用后再打印。或您可点击下载该套打控件，安装成功后刷新页面再进行打印`,
            "提示",
            {
              confirmButtonText: "确定",
              callback: (action) => {
                window.open("https://www.lodop.net/download.html");
              },
            }
          );
        }
      }
    },
    // 给单元格绑定横向和竖向的index，这样就能确定是哪一个单元格
    tableCellClassName({ row, column, rowIndex, columnIndex }) {
      row.index = rowIndex;
      column.index = columnIndex;
    },
    // 获得当前双击的单元格的横竖index，然后拼接成一个唯一字符串用于判断，并赋给currentCell
    // 拼接后类似这样："1,0","1,1",
    dbclick(row, column) {
      if (this.handleStatus == "3") return;
      console.log("双击", row, column);
      this.currentCell = row.index + "," + column.index;
      // 这里必须要setTimeout，因为在点击的时候，input才刚被v-if显示出来，不然拿不到dom
      setTimeout(() => {
        // 双击后自动获得焦点
        if (this.$refs[row.index + "," + column.index]) {
          this.$refs[row.index + "," + column.index].focus();
        }
      });
    },
    // 更改未处理人员
    changeUnhandledPerson(val, row) {
      console.log("更改未处理人员", val, row);
      let findobj = this.unHandleWorkPersonnelList.find(
        (item) => item.showTypeName == val
      );
      let findindex = this.unHandleWorkPersonnelList.findIndex(
        (item) => item.showTypeName == val
      );
      if (findobj) {
        this.unHandleWorkPersonnelList.splice(findindex, 1);
        this.$set(row, "personnelNumber", findobj.personnelNumber);
        this.$set(row, "dosageNumber", findobj.dosageNumber);
        this.$set(row, "personnelName", findobj.personnelName);
        this.$set(row, "personnelSex", findobj.personnelSex);
        this.$set(
          row,
          "occupationalClassification",
          findobj.occupationalClassification
        );
        this.$set(row, "wearingBeginTime", findobj.wearingBeginTime);
        this.$set(row, "wearingEndTime", findobj.wearingEndTime);
        this.$set(row, "sendTrackingNumber", findobj.sendTrackingNumber);
        this.$set(row, "holeOneDosageValue", findobj.holeOneDosageValue);
        this.$set(row, "holeTwoDosageValue", findobj.holeTwoDosageValue);
        this.$set(row, "dosageValue", findobj.dosageValue);
        this.$set(row, "dosageType", findobj.dosageType);
        this.$set(row, "taskPersonalResultId", findobj.taskPersonalResultId);
        this.$set(row, "originName", findobj.originName);
        this.$set(row, "isEmptyTrackingNumber", findobj.isEmptyTrackingNumber);
        console.log("更改后", row);
        if (row.isadd) {
          /* 添加行 */
          this.currentCell = null;
          row.operation = 0;
          this.handleform.operationList.push({ ...row });
          this.$set(row, "isadd", false);
        } else {
          /* 修改行 */
          this.hideInput(row);
        }
      }
    },
    // 当input失去焦点的时候，隐藏input, 推入修改列表
    hideInput(row) {
      console.log("hideInput", this.handleform);
      if (row.personnelName && row.personnelName.trim() == "") {
        this.$set(row, "personnelName", row.originName);
      }
      this.currentCell = null;
      row.operation = 1;
      this.handleform.operationList.push({ ...row });
    },
    // 添加行
    addLine() {
      this.handleform.list.push({
        isadd: true,
      });
      this.totalHandle += 1;
      this.currentCell = this.handleform.list.length - 1 + "," + 3;
      this.$nextTick(() => {
        this.$refs.tableData.bodyWrapper.scrollTop =
          this.$refs.tableData.bodyWrapper.scrollHeight;
      });
    },
    // 删除行
    deleteItem(index) {
      if (!this.handleform.list[index].taskPersonalResultId) {
        this.handleform.list.splice(index, 1);
        this.totalHandle -= 1;
      } else {
        this.$modal.confirm(`是否确认删除该人员？`).then(() => {
          this.handleform.list[index].operation = 2;
          this.handleform.operationList.push({
            ...this.handleform.list[index],
          });

          this.unHandleWorkPersonnelList.push({
            ...this.handleform.list[index],
          });
          // 去除重复数据
          const temp = this.unHandleWorkPersonnelList;
          this.unHandleWorkPersonnelList = temp.filter((item, index, arr) => {
            return (
              arr.findIndex((i) => i.showTypeName === item.showTypeName) ===
              index
            );
          });
          this.handleform.list.splice(index, 1);
          this.totalHandle -= 1;
        });
      }
    },
    // 异常报备
    handleException(row) {
      this.$modal.confirm(`确定异常报备吗？`).then(() => {
        addExceptionalRecord({
          taskPersonalResultId: [row.taskPersonalResultId],
          exceptionType: 2,
        }).then((response) => {
          this.$modal.msgSuccess("报备成功");
        });
      });
    },
    // 打开快递单号对话框
    editTrackingNumber() {
      this.editTrackingNumberVisible = true;
      this.editTrackingNumberForm = {};
      this.resetForm("editTrackingNumberForm");
    },
    // 提交快递单号
    submitTrackingNumber() {
      this.$refs["editTrackingNumberForm"].validate((valid) => {
        if (!valid) return;
        this.editTrackingNumberForm.dosimeterId =
          this.handleform.taskPersonalDosimeterId;
        this.editTrackingNumberForm.resultIds = this.selected
          .map((item) => item.taskPersonalResultId)
          .filter((item) => item);
        addSendTrackingNumber(this.editTrackingNumberForm).then((response) => {
          this.$modal.msgSuccess("修改成功");
          this.editTrackingNumberVisible = false;
          this.activeName = "-2";
          this.changeTab({ name: -2 });
          // 不勾选是没有的添加 勾选是勾选的全部修改 (新增的行只能选择人员 选择完后变为输入框 只有单号未空才能双击修改 否则点击修改单号按钮才能修改)
          this.handleform.list.forEach((item) => {
            if (this.selected.length == 0 && !item.sendTrackingNumber) {
              this.$set(
                item,
                "sendTrackingNumber",
                this.editTrackingNumberForm.sendTrackingNumber
              );
            }
            if (
              this.selected.length != 0 &&
              this.selected.find(
                (it) => it.taskPersonalResultId == item.taskPersonalResultId
              )
            ) {
              this.$set(
                item,
                "sendTrackingNumber",
                this.editTrackingNumberForm.sendTrackingNumber
              );
            }
          });
          this.handleform.operationList.forEach((item) => {
            if (this.selected.length == 0 && !item.sendTrackingNumber) {
              this.$set(
                item,
                "sendTrackingNumber",
                this.editTrackingNumberForm.sendTrackingNumber
              );
            }
            if (
              this.selected.length != 0 &&
              this.selected.find(
                (it) => it.taskPersonalResultId == item.taskPersonalResultId
              )
            ) {
              this.$set(
                item,
                "sendTrackingNumber",
                this.editTrackingNumberForm.sendTrackingNumber
              );
            }
          });
        });
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.uploadbutton {
  padding-inline: 20px;
}
.myupload {
  margin-bottom: 20px;
}
.result {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 30px;
  .calc {
    width: min-content;
    margin-left: 20px;
    .el-button {
      margin: 0;
      &:nth-of-type(1) {
        margin-bottom: 10px;
      }
    }
  }
}
.nametitle {
  text-align: center;
  margin-bottom: 10px;
  font-weight: bolder;
  &::before {
    content: "* ";
    color: red;
  }
}
::v-deep .el-table .warning-row {
  color: red;
}
.searchcontainer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: -10px;
}
.viewform {
  justify-content: flex-end;
}
.title {
  padding-left: 10px;
  border-left: 5px solid #2a72ee;
  text-align: left;
  font-weight: bolder;
  font-size: 16px;
  margin-bottom: 30px;
}
.operation {
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  .editform {
    .el-form-item {
      margin-bottom: 0;
    }
  }
}
.opration {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 10px;
  .filelist {
    margin: 0 auto 0 0;
    margin-left: 30px;
    font-weight: bolder;
    .filelistitem {
      color: #2a72ee;
      cursor: pointer;
      &:hover {
        color: #2a72ee;
        text-decoration: underline;
      }
    }
  }
  .blreport {
    margin-right: 20px;
  }
}
.codecontainer {
  width: 5cm;
  height: 10cm;
  .item {
    color: red;
    font-size: 12px;
  }
}
// 生成图片样式
.printmy {
  position: relative;
  font-size: 10px;
  background-color: aqua;
  width: 50mm;
  height: 23mm;
  margin-bottom: 5mm;
  padding: 2mm;
  .barcode {
    position: absolute;
    top: 2mm;
    right: 3mm;
  }
}
::v-deep .handletabel.el-table {
  margin-bottom: 60px;
  overflow: auto;
  .el-table__body-wrapper {
    overflow-y: auto;
    overflow-x: hidden;
  }
}
::v-deep .handletabelaudit.el-table {
  margin-top: -35px;
}
.flowdialog .el-tabs {
  height: 700px;
  overflow: auto;
}
.blbtn {
  margin-right: 50px;
}
.bldialog ::v-deep .el-dialog {
  max-height: 95%;
  .el-dialog__body {
    position: relative;
  }
}
.addtask ::v-deep .el-dialog__body {
  position: relative;
}
.wearingedit ::v-deep .el-input__inner {
  padding-right: 0;
}
.selectperson ::v-deep .el-input__inner {
  padding-right: 7px;
}
.separate {
  width: 100%;
  height: 1px;
  background-color: #d2d2d2;
  margin-bottom: 15px;
}
::v-deep .el-button.ovbutton {
  padding-block: 0;
}
</style>
